#include <stdio.h>

typedef struct Handler
{
  struct Handler *mSuccessor;
  void (*handleRequest)(struct Handler *this, char c);
} ConcreateHandler;

void ConcreateHandler1_handleRequest(ConcreateHandler *this, char c)
{
  if (c == 'a')
  {
    printf("I can handle \'a\'");
  }
  else if (this->mSuccessor != NULL )
  {
    this->mSuccessor->handleRequest(this->mSuccessor, c);
  }
}
void ConcreateHandler2_handleRequest(ConcreateHandler *this, char c)
{
  if (c == 'b')
  {
    printf("I can handle \'b\'");
  }
  else if (this->mSuccessor != NULL )
  {
    this->mSuccessor->handleRequest(this->mSuccessor, c);
  }
}

/*Client*/int main()
{
  ConcreateHandler h1;
  ConcreateHandler h2;

  h1.mSuccessor = &h2;
  h1.handleRequest = ConcreateHandler1_handleRequest;
  h2.mSuccessor = NULL;
  h2.handleRequest = ConcreateHandler2_handleRequest;

  h1.handleRequest(&h1, 'b');

  fflush(stdout);
  sleep(2);
}
